<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div id="form1">
    <span style="width:80px;display:inline-block;">账号：</span>
    <input id="username" required="true" class="mini-textbox" style="width:155px;" value="<%=result.data[0].username%>"/>

    <span style="width:80px;display:inline-block;margin-left: 30px">新密码：</span>
    <input id="password"  required="true" class="mini-password" style="width:170px;" value=""/>
    <br/><br/>

    <span style="width:80px;display:inline-block;">昵称：</span>
    <input id="nickName" required="true" class="mini-textbox" style="width:155px;"  value="<%=result.data[0].nickName%>"/>

    <span style="width:80px;display:inline-block;margin-left: 30px">重复密码：</span>
    <input id="rePassword"  required="true" class="mini-password" style="width:170px;" value="<%=result.data[0].password%>"/>

    <br/><br/>
    <span style="width:80px;display:inline-block;">状态：</span>
    <input id="status" required="true" class="mini-combobox" style="width:155px;"  data="userStatus" value="<%=result.data[0].status%>"/>
    <br/><br/>
    <div style="margin: 0 auto;text-align: center">
        <a class="mini-button " iconCls="icon-ok" onclick="addAdmin()">确定</a>
        <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
    </div>
</div>
</body>
<script>
    var userStatus = [{id:0,text:"删除"},{id:1,text:"正常"}];
    var objectId = '<%= result.data[0].objectId%>';
    function addAdmin() {
        var username = mini.get("username").getValue();
        var nickName = mini.get("nickName").getValue();
        var password = mini.get("password").getValue();
        var rePassword = mini.get("rePassword").getValue();
        var status = mini.get("status").getValue();
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false){
            return;
        }
        if(password!=rePassword){
            alert("密码错误");
            return
        }
        $.ajax({
            type: "POST",
            url: "/getdata/admin/addUser",
            data: {
                objectId:objectId,
                username: username,
                nickName: nickName,
                password: password,
                status: status,
            },
            success: function (result) {
                CloseWindow("save");
            }
        })
    }
    //    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }
    function onOk(e) {
        SaveData();
    }
    function onCancel(e) {
        CloseWindow("cancel");
    }
</script>
</html>